-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discuss] Async use cases #1306
Conversation
ba95ac5
to
392da0a
Compare
|
||
- Rust code making an async call into a CallbackInterface / Foreign code | ||
making an async into Rust. I think this could be implemented by having | ||
UniFFI generate something like the hand-written demo from #1252. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a nice feature, but I'm not sure it's necessary. I think we could implement the Nimbus work with hand-written code. Maybe we could just start there and see if there's more demand before generating that code with UniFFI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that hand-writing & using it that way seems sensible. That's how UniFFI was born to begin with.
UniFFI generate something like the hand-written demo from #1252. | ||
- Handling CallbackInterface calls from a Rust-based thread. I'm not exactly sure how this would work, there's at least 2 options here: | ||
- Handle everything on the foreign side. In the generate code we currently register a callback to invoke a CallbackInterface call. We might be able to update that code so that it schedules the call to run on the correct thread. But this assumes that it's safe to call that callback on the Rust thread. Is that true for all of our current languages? Are we okay with adding this requirement for future languages? | ||
- Use a queue plus a waker. Push the CallbackInterface call to a queue, signal the foreign side (maybe writing a byte to a pipe or socket), then the foreign side would wake up and try to read from the queue. This seems more complicated than the first system, but might let us support more foreign languages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature seems necessary if we ever want to make a call from a Rust controlled (or C++ controlled) thread into JS. Maybe we want that for the Nimubs desktop work, but I'm not sure.
I think we have a good plan here, no need to keep this PR open longer. |
I don't know if this document should be added to the docs section, the main reason I'm opening the PR is so we can discuss the use cases more.